function H=save2DHFilter(filename,n,precond,precision)
    global verbose
    timestamp=now;
    if verbose
        fprintf('creating 2D filter on %s with n = %d and precond %d for future usage\n',datestr(timestamp),n,precond);
    end
    H=makeHFilter2D(n,precond,precision);
    fid=fopen(filename,'w');
    if fid<0
        error('failed to open file %s for writing, filter was not created\n',filename);
    else
        fwrite(fid,n,'int');
        fwrite(fid,timestamp,'real*8');
        fwrite(fid,precond,'int');
        for i = 1:n
            if strcmp(precision,'single')
                fwrite(fid,real(H.filter(i,i:n)),'real*4');
            elseif strcmp(precision,'double')
                fwrite(fid,real(H.filter(i,i:n)),'real*8');
            else
                error('precision must be single or double');
            end
        end
        fclose(fid);
    end
end